File: /var/www/html/owlcrm/app/first-project/app/Http/Controllers/TeacherController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Teacher;
class TeacherController extends Controller
{
public function binding(Teacher $key) {
return $key;
}
function operations() {
return DB::table('teachers')->get();
}
}
//public function uniondata() {
// $teachers=DB::table('teachers')
// ->select('name','email');
// $students=DB::table('students')
// ->union($teachers)
// ->select('name','email')
// ->get();
// dump( $students);
// public function whendata() {
// $teachers=DB::table('teachers')
// ->when( true,function($query) {
// $query->where('id','>',5);
// })
// ->get();
// return $teachers;
// }
//public function chunkdata() {
// $teachers=DB::table('teachers')->orderBy('id')
// ->chunk(3, function($teachers) {
// echo "<div style='border:2px solid purple;margin-bottom:20px;border-radius:12px;padding:15px;'>";
// foreach ($teachers as $teacher){
// echo $teacher->email."<br>";
// }
// echo "</div>";
// });
// }
//public function showTeacher() {
//$teachers=DB::select("select name, email, age from teachers where id = :id",['id' => 4]);
// $teachers=DB::insert ("insert into teachers(id,name,email,age)values(?,?,?,?)",[21,'ridhima','[email protected]',19]);
//$teachers=DB::update("update teachers set email = '[email protected]' where id = ?", [3]);
// $teachers=DB::delete("delete from teachers where id = ?",[2]);
//$teachers=DB::statement("drop table teachers");
// $teachers=DB::unprepared("delete from teachers where id = 1");
//$teachers=DB::table('teachers')
// ->selectRaw('count(*) as teachers_count, age')
//->whereRaw('age > ? and name like ?',[25,'p%'])
// ->Select(DB::raw('count(*) as teachers_count'), 'age')
//->where(DB::raw('age > ? and name like ?', [25, 'p%']))
// ->groupByRaw('age')
// ->havingRaw('age < ?',[25])
// ->get();
//->tosql();
// return $teachers;
//}
//foreach( $teachers as $teacher ) {
// echo $teacher->email."<br>";
// }
//}